
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Vector Visualizer in 3D - free tool for visualizing vectors in three dimensions</title>
    <style type="text/css">
    html, body {
	    height: 100%;
	    overflow: auto;
    }
    body {
	    padding: 0;
	    margin: 0;
	    background-color:#E1E1E1;
	    font-family: Tahoma,Verdana,Arial,sans-serif; 
    }
    #silverlightControlHost {
	    height: 450px;
	    text-align:center;
    }
    A:visited { color:#555; }
    </style>
    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript">
        function onSilverlightError(sender, args) {

            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            var errMsg = "Unhandled Error in Silverlight 2 Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }
    </script>
    <script type="text/javascript">
        function $(id) { return document.getElementById(id); }
        function VV_ChangeVectors(link) {
            var a = $("VectorsURL");
            a.innerHTML = link;
            a.href = link;
            var vectors = VV_LinkToVectors(link);
            $("VectorsTextArea").value = VV_VectorsToText(vectors);
        }
        function VV_GoToVectors() {
            var text = $("VectorsTextArea").value.split(' ').join('');
            if (text == '') {
                alert('Please enter the vectors you want to view in the text field as (X,Y,Z),(X,Y,Z)');
                return;
            }
            var vectors = VV_TextToVectors(text);
            var link = VV_VectorsToLink(vectors);
            document.location.href = link;
        }
        function VV_TextToVectors(text) {
            var arr = text.split('(');
            var vectors = [];
            for (var i = 1; i < arr.length; i++) {
                var curr = arr[i];
                if (curr.indexOf(')') <= 0) continue;
                var subArr = curr.split(')');
                var inside = subArr[0];
                var vector = VV_ParseVector(inside);
                if (vector == null) continue;
                else vectors.push(vector);
            }
            return vectors;
        }
        function VV_SplitVectorParts(str) {
            str = str.split(";").join(",");
            var arr = str.split(",");
            if (arr.length == 2) { // if this is two dimensional array
                arr.push(0);
            }
            return arr;
        }
        function VV_ParseVector(raw) {
            var parts = raw.split(":");
            if (parts.length == 1) parts = ["0,0,0", parts[0]];
            if (parts.length != 2) return null;
            var partOne = VV_SplitVectorParts(parts[0]);
            var partTwo = VV_SplitVectorParts(parts[1]);
            var v = { x1: 0, y1: 0, z1: 0, x2: 0, y2: 0, z2: 0 };
            if (partOne.length != 3 || partTwo.length != 3) return null;
            if (!VV_TryParseFloat(partOne[0], v, "x1")) return null;
            if (!VV_TryParseFloat(partOne[1], v, "y1")) return null;
            if (!VV_TryParseFloat(partOne[2], v, "z1")) return null;
            if (!VV_TryParseFloat(partTwo[0], v, "x2")) return null;
            if (!VV_TryParseFloat(partTwo[1], v, "y2")) return null;
            if (!VV_TryParseFloat(partTwo[2], v, "z2")) return null;
            return v;
        }
        function VV_TryParseFloat(str, obj, propName) {
            var f = parseFloat(str.toString().split(' ').join('').split('\t').join(''));
            if (isNaN(f)) return false;
            obj[propName] = f;
            return true;
        }
        function VV_LinkToVectors(link) {
            var varPrefix = 'vectors=';
            var qMarkIndex = link.indexOf('?');
            var qVarIndex = link.indexOf('vectors=');
            if (qMarkIndex < 0 || qVarIndex < 0) return [];
            var qs = link.substr(qVarIndex + varPrefix.length);
            var toParse = qs.split('&')[0];
            var eachVector = toParse.split('v');
            var vectors = [];
            for (var i = 0; i < eachVector.length; i++) {
                var parts = eachVector[i].split('/');
                if (parts.length == 3) parts = [0, 0, 0, parts[0], parts[1], parts[2]];
                if (parts.length != 6) continue;
                var v = { x1: 0, y1: 0, z1: 0, x2: 0, y2: 0, z2: 0 };
                if (!VV_TryParseFloat(parts[0], v, "x1")) continue;
                if (!VV_TryParseFloat(parts[1], v, "y1")) continue;
                if (!VV_TryParseFloat(parts[2], v, "z1")) continue;
                if (!VV_TryParseFloat(parts[3], v, "x2")) continue;
                if (!VV_TryParseFloat(parts[4], v, "y2")) continue;
                if (!VV_TryParseFloat(parts[5], v, "z2")) continue;
                vectors.push(v);
            }
            return vectors;
        }
        function VV_VectorsToText(vectors) {
            var sb = [];
            for (var i = 0; i < vectors.length; i++) {
                var curr = vectors[i];
                if (i > 0) sb.push("\n");
                sb.push("(");
                if (curr.x1 != 0 || curr.y1 != 0 || curr.z1 != 0) {
                    sb.push(curr.x1);
                    sb.push(", ");
                    sb.push(curr.y1);
                    sb.push(", ");
                    sb.push(curr.z1);
                    sb.push(" : ");
                }
                sb.push(curr.x2);
                sb.push(", ");
                sb.push(curr.y2);
                sb.push(", ");
                sb.push(curr.z2);
                sb.push(")");
            }
            return sb.join("");
        }
        function VV_VectorsToLink(vectors) {
            var sb = [VV_CurrentBaseUrl()];
            sb.push("?vectors=");
            for (var i = 0; i < vectors.length; i++) {
                var curr = vectors[i];
                if (i > 0) sb.push("v");
                if (curr.x1 != 0 || curr.y1 != 0 || curr.z1 != 0) {
                    sb.push(curr.x1);
                    sb.push("/");
                    sb.push(curr.y1);
                    sb.push("/");
                    sb.push(curr.z1);
                    sb.push("/");
                }
                sb.push(curr.x2);
                sb.push("/");
                sb.push(curr.y2);
                sb.push("/");
                sb.push(curr.z2);
            }
            return sb.join("");
        }
        function VV_CurrentBaseUrl() {
            var raw = document.location.href;
            var qMarkIndex = raw.indexOf('?');
            if (qMarkIndex < 0) return raw;
            return raw.substr(0, qMarkIndex);
        }
        function VV_EmailCurrentVectors() {
            var url = $("VectorsURL").href;
            document.location.href = "mailto:?body=Check%20this%20:%20" + url + "&subject=Vector Visualizer - view vectors in 3D";
        }
    </script>
</head>
<body>


    <div style="text-align:center;margin-top:3px;   "> 
        Vector Visualizer in 3D - free tool for visualizing vectors in three dimensions
    </div> 
    <div style="text-align:center;color:gray;font-size:11px;font-weight:bold;margin-bottom:5px"> 
        This freeware program can help you not only to visualize 
        vectors, points, and lines in three dimansions but also to 
        share your 3D visualization with your friends.
    </div> 

	<div id='errorLocation' style="font-size: small;color: Gray;"></div>

    <div id="silverlightControlHost">
		<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="780" height="450">
			<param name="source" value="ClientBin/com.bodurov.VectorVisualizer.xap?v=5"/>
			<param name="onerror" value="onSilverlightError" />
			<param name="background" value="white" />
			<param name="minRuntimeVersion" value="2.0.31005.0" />
			<param name="autoUpgrade" value="true" />
			<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;">
     			<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
			</a>
		</object>
		<iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>
    </div>
    <table width="780px" align="center" cellpadding="3" cellspacing="0">
        <tr>
            <td colspan="2" align="center">
                <span style="color:#778;font-size:12px;font-weight:bold">Link to current vectors</span> 
                <span style="color:#778;font-size:11px;">
                  <a href="#" onClick="VV_EmailCurrentVectors()" style="text-decoration:none;color:#778;"> 
                     send as e-mail <img src="http://www.bodurov.com/images/email.gif" border="0" />
                  </a>
                </span> 
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
              <div style="width:780px;height:30px;overflow:auto">
                <a id="VectorsURL" href="#" target="_blank" style="font-size:12px"></a>
              </div>
            </td>
        </tr>
        <tr>
            <td width="350px" align="right">
                <textarea id="VectorsTextArea" style="width:350px;height:80px"></textarea>
            </td>
            <td align="left" valign="top">
                <span style="color:#778;font-size:12px">
                    You can define vectors as <b>(X, Y, Z)</b>
                    for example <b>(-1, 3, 5)</b> assuming that the vector begins at point <b>(0, 0, 0)</b>. 
                    If the vectors starts at a point different from <b>(0, 0, 0)</b> you can define it as 
                    <b>(X1, Y1, Z1 : X2, Y2, Z2)</b> for example <b>(1, 2, 1 : 2, -1, 0)</b>
                    <div style="margin-top:5px">
                        <input type="button" value="See Vectors" onclick="VV_GoToVectors()" />
                    </div>
                    
                </span>
            </td>
        </tr>
    </table>
    
    
    <hr width="780px" align="center" />
    <div style="text-align:center;margin-right:20px;font-size:12px">
      <span style="color:#778">Shape Visualizations:</span>
      
      &nbsp; 
      
      <a href="?vectors=3/3/3/-3/3/3v-3/3/3/-3/-3/3v-3/-3/3/3/-3/3v3/-3/3/3/3/3v3/3/3/3/3/-3v3/3/-3/3/-3/-3v3/-3/-3/-3/-3/-3v-3/-3/-3/-3/3/-3v-3/3/-3/3/3/-3v3/-3/3/3/-3/-3v-3/-3/3/-3/-3/-3v-3/3/3/-3/3/-3"> 
        Cube</a>
      
      &nbsp; &nbsp; 
      
      <a href="?vectors=-3/0/3/3/0/3v3/0/3/3/0/-3v-3/0/-3/-3/0/3v3/0/-3/-3/0/-3v-3/0/3/0/5/0v3/0/3/0/5/0v-3/0/-3/0/5/0v3/0/-3/0/5/0">
        Pyramid</a>
        
       &nbsp; &nbsp; 
        
      <a href="?vectors=3/3/3/-3/3/3v-3/3/3/-3/-3/3v-3/-3/3/3/-3/3v3/-3/3/3/3/3v3/3/3/3/3/-3v3/3/-3/3/-3/-3v3/-3/-3/-3/-3/-3v-3/-3/-3/-3/3/-3v-3/3/-3/3/3/-3v3/-3/3/3/-3/-3v-3/-3/3/-3/-3/-3v-3/3/3/-3/3/-3v-1.4/-1.4/1.4/1.4/-1.4/1.4v1.4/-1.4/1.4/1.4/-1.4/-1.4v-1.4/-1.4/-1.4/-1.4/-1.4/1.4v1.4/-1.4/-1.4/-1.4/-1.4/-1.4v-1.4/1.4/1.4/1.4/1.4/1.4v1.4/1.4/1.4/1.4/1.4/-1.4v-1.4/1.4/-1.4/-1.4/1.4/1.4v1.4/1.4/-1.4/-1.4/1.4/-1.4v-1.4/-1.4/1.4/-1.4/1.4/1.4v1.4/-1.4/1.4/1.4/1.4/1.4v-1.4/-1.4/-1.4/-1.4/1.4/-1.4v1.4/-1.4/-1.4/1.4/1.4/-1.4v-1.4/-1.4/1.4/-3/-3/3v1.4/-1.4/1.4/3/-3/3v-1.4/-1.4/-1.4/-3/-3/-3v1.4/-1.4/-1.4/3/-3/-3v-1.4/1.4/1.4/-3/3/3v1.4/1.4/1.4/3/3/3v-1.4/1.4/-1.4/-3/3/-3v1.4/1.4/-1.4/3/3/-3">
        4D cube projection on 3D</a>
        
        &nbsp; &nbsp; 
        
        <a href="?vectors=0/0/5/4.715/0/-1.665v0/0/5/-2.355/4.08/-1.665v4.715/0/-1.665/-2.355/4.08/-1.665v4.715/0/-1.665/-2.355/-4.08/-1.665v-2.355/4.08/-1.665/-2.355/-4.08/-1.665v-2.355/-4.08/-1.665/0/0/5">
        Tetrahedron</a>
        
        
        &nbsp; &nbsp; 
        
        <a href="?vectors=-0.94/-2.885/-3.975/-1.52/-4.67/-0.94v-3.035/0/-3.975/-4.91/0/-0.94v3.975/-2.885/-0.94/1.52/-4.67/0.94v1.52/-4.67/0.94/-1.52/-4.67/-0.94v0.94/-2.885/3.975/1.52/-4.67/0.94v-3.975/-2.885/0.94/-1.52/-4.67/-0.94v-3.975/-2.885/0.94/-4.91/0/-0.94v-3.975/2.885/0.94/-4.91/0/-0.94v-3.975/2.885/0.94/-1.52/4.67/-0.94v-2.455/1.785/3.975/-3.975/2.885/0.94v-2.455/-1.785/3.975/-3.975/-2.885/0.94v-1.52/4.67/-0.94/-0.94/2.885/-3.975v4.91/0/0.94/3.975/-2.885/-0.94v3.975/2.885/-0.94/2.455/1.785/-3.975v2.455/-1.785/-3.975/3.975/-2.885/-0.94v1.52/4.67/0.94/-1.52/4.67/-0.94v3.035/0/3.975/0.94/2.885/3.975v0.94/2.885/3.975/-2.455/1.785/3.975v-2.455/1.785/3.975/-2.455/-1.785/3.975v-2.455/-1.785/3.975/0.94/-2.885/3.975v0.94/-2.885/3.975/3.035/0/3.975v2.455/1.785/-3.975/-0.94/2.885/-3.975v-0.94/2.885/-3.975/-3.035/0/-3.975v-3.035/0/-3.975/-0.94/-2.885/-3.975v-0.94/-2.885/-3.975/2.455/-1.785/-3.975v2.455/-1.785/-3.975/2.455/1.785/-3.97v3.035/0/3.975/4.91/0/0.94v4.91/0/0.94/3.975/2.885/-0.94v3.975/2.885/-0.94/1.52/4.67/0.94v1.52/4.67/0.94/0.94/2.885/3.975">
        Dodecahedron</a>
        
    </div>
    
    <hr width="780px" align="center" />
    
    <div style="text-align:center;margin-right:20px;font-size:12px">
    
      <a href="http://www.simple-talk.com/dotnet/.net-framework/building-a-simple-3d-engine-with-silverlight/" 
        target="_blank" style="color:#00F">
        Article</a>
      
      &nbsp; &nbsp;
      
      <a href="http://www.codeplex.com/VectorVisualizer" target="_blank" style="color:#00F">
        Source Code</a>
      
      &nbsp; &nbsp;
    
      <a href="http://www.bodurov.com/files/VV_Offline.zip" style="color:#00F">
        Download</a>
    
      &nbsp; &nbsp;
    
      <a href="http://blog.bodurov.com/Vector-Visualizer-3D-tool-for-viewing-vectors-in-three-dimensions" target="_blank" style="color:#00F">
        Blog Entry</a>
        
      &nbsp; &nbsp;
      
      <a href="mailto:?body=Check%20this%20tool:%20http://www.bodurov.com/VectorVisualizer&subject=Vector Visualizer - view vectors in 3D"
         onclick="javascript:urchinTracker('/share/ShareAsEmail?url=http://www.bodurov.com/VectorVisualizer');"
         style="text-decoration:none" target="_blank">
         <img src="http://www.bodurov.com/images/email.gif" border="0" /> E-mail</a> 
      
      &nbsp; &nbsp;
      
      <span style="font-size:10px;color:grey;font-weight:bold">
        Copyright (c) 2009 Vladimir Bodurov
      </span>
      
    </div>
    
    <hr width="780px" align="center" />

    <div style="font-size:10px;color:grey;font-weight:bold;text-align:center">
      my other tools: &nbsp;
      <a href="http://www.bodurov.com/BitmapVectorizer">
        Bitmap Vectorizer</a> &nbsp; &nbsp;
      <a href="http://www.bodurov.com/JsonFormatter">
        Json Formatter</a>
    </div>

    &nbsp;

    
    
</body>
</html>
